package dao;

import java.util.ArrayList;

import org.hibernate.Session;

import metier.Interdit;


public class DAOInterditHib extends DAOHibernate implements DAOInterdit {

	@Override
	public Interdit get(int id) throws Exception {
		Interdit	interdit = null;
		Session	session = connect();		
		interdit = (Interdit) session.get(Interdit.class, id);	
		close(session);
		return interdit;
	}

	@SuppressWarnings("unchecked")
	@Override
	public ArrayList<Interdit> loadAll() throws Exception {
		ArrayList<Interdit>	tab = null;
		Session session = connect();
		
		tab = (ArrayList<Interdit>) session.createQuery("FROM Interdit")
				.list();
		
		close(session);
		return tab;
	}

	@Override
	public void save(Interdit interdit) throws Exception {
		Session	session = connect();
		
		session.save(interdit);
		
		close(session);	
		
		
	}

	@Override
	public void saveOrupdate(Interdit interdit) throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void delete(Interdit interdit) throws Exception {
		Session	session = connect();
		
		session.delete(interdit);
		interdit.setId_interdit(-1);
		
		close(session);
		
	}

	@Override
	public void update(Interdit interdit) throws Exception {
		Session	session = connect();
		
		session.update(interdit);
		
		close(session);
		
	}

	
}
